﻿using markdown_picture_packer.common.utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace markdown_picture_packer.frontend
{
    public abstract class BaseForm : Form, IFront
    {

        public BaseForm()
        {
            InitComponent();
            InitSize(0, 0);
            InitLocation();
            InitEvent();
            AddComponent();
        }
        // 初始化组件
        public abstract void InitComponent();

        // 初始化组件尺寸
        public abstract void InitSize(int newWidth, int newHeight);

        // 初始化组件位置
        public abstract void InitLocation();
        // 初始化组件事件
        public virtual void InitEvent()
        {
            SizeChanged += (s, e) =>
            {
                InitSize(FrontUtil.GetRealWidth(Width), FrontUtil.GetRealHeight(Height));
                InitLocation();
            };
        }
        // 添加组件
        public abstract void AddComponent();
    }
}
